import { EventBus } from "@/tools/bus";
import { wsSend } from "@/tools/sendMessage";
import { pageHandler } from '@/mixins/pageHandler'
import { submitOperateRecord } from "@/api/api";
import ScaleBox from '@/components/ScaleBox/ScaleBox.vue'
import MonitorHeader from '@/components/MonitorHeader/MonitorHeader.vue'
import RuanYaBan from "@/components/controls/RuanYaBan.vue";
import YingYaBan from "@/components/controls/YingYaBan.vue";
import MainBus from "@/components/controls/mainBus.vue";
import TerminalSvg from "@/components/controls/terminal-svg.vue";
import ConnectLine from "@/components/controls/connect-line.vue";
import RectSvg from "@/components/controls/rect-svg.vue";
import GuangZiPai from '@/components/controls/GuangZiPai.vue'
import KongZhiBaShou from '@/components/controls/KongZhiBaShou.vue'
import RightClickmenuList from '@/components/rightClickmenuList/rightClickMenuList.vue'
import GuapaiDialog from '@/components/rightClickmenuList/guapaiDialog.vue'
import YaokongDialog from '@/components/rightClickmenuList/yaokongDialog.vue'
import NetState from '@/components/controls/netState.vue'

export default {
	name: 'main2IntervalGraph',
	components: {
		RuanYaBan,
		YingYaBan,
		MainBus,
		TerminalSvg,
		ConnectLine,
		RectSvg,
		ScaleBox,
		MonitorHeader,
		KongZhiBaShou,
		RightClickmenuList,
		GuapaiDialog,
		YaokongDialog,
		GuangZiPai,
		NetState
	},
	mixins: [pageHandler],
	data() {
		return {
			
		}
	},
	created() {},
	methods: {
		initData(e) {
		  this.filterData(e)
		},
		filterData(data) {
			let arr = [
				{name: 'Ia', gao: '', zhong: '', di: '', benti: '', unit: ''},
				{name: 'Ib', gao: '', zhong: '', di: '', benti: '', unit: ''},
				{name: 'Ic', gao: '', zhong: '', di: '', benti: '', unit: ''},
				{name: 'Ua', gao: '', zhong: '', di: '', benti: '', unit: ''},
				{name: 'Ub', gao: '', zhong: '', di: '', benti: '', unit: ''},
				{name: 'Uc', gao: '', zhong: '', di: '', benti: '', unit: ''},
				{name: 'Uab', gao: '', zhong: '', di: '', benti: '', unit: ''},
				{name: 'Ubc', gao: '', zhong: '', di: '', benti: '', unit: ''},
				{name: 'Uca', gao: '', zhong: '', di: '', benti: '', unit: ''},
				{name: 'P', gao: '', zhong: '', di: '', benti: '', unit: ''},
				{name: 'Q', gao: '', zhong: '', di: '', benti: '', unit: ''},
				{name: 'COS', gao: '', zhong: '', di: '', benti: '', unit: ''},
			]
			let gao = data['高压侧']
			let zhong = data['中压侧'].slice(4,data['中压侧'].length)
			let di = data['低压侧']
			let ben = data['本体']
			
			arr.forEach((item, index) => {
				gao.forEach(itm => {
					if(item.name == itm.state_desc) {
						item.gao = itm.state_val
						item.unit = itm.unit
					}
				})
				zhong.forEach(itm => {
					if(item.name == itm.state_desc) {
						item.zhong = itm.state_val
						item.unit = itm.unit
					}
				})
				di.forEach(itm => {
					if(item.name == itm.state_desc) {
						item.di = itm.state_val
						item.unit = itm.unit
					}
				})
				ben.forEach(itm => {
					if(item.name == itm.state_desc) {
						item.benti = itm.state_val
						item.unit = itm.unit
					}
				})
			})
			this.tableData = arr
		},
	},
	mounted() {},
}
